
import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';

class MyAnimationWidget extends StatefulWidget {
  const MyAnimationWidget({Key? key}) : super(key: key);

  @override
  _MyAnimationWidgetState createState() => _MyAnimationWidgetState();
}

class _MyAnimationWidgetState extends State<MyAnimationWidget> with SingleTickerProviderStateMixin{
  late AnimationController controller;
  late Animation<double> animation;

  initState() {
    super.initState();
    controller =  AnimationController(
        duration: const Duration(milliseconds: 2000), vsync: this);
    animation =  Tween(begin: 0.0, end: 300.0).animate(controller);
    controller.forward();
  }
  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar('AnimationWidget'),
      body: Container(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        color: Colors.yellow,
        child: AnimationLogo(animation: animation,),),
    );
  }
}

class AnimationLogo extends AnimatedWidget{
  AnimationLogo({Key?key,required Animation<double> animation}) : super(key: key,listenable: animation);

  @override
  Widget build(BuildContext context) {
    final Animation<double> animation = listenable as Animation<double>;
    return Center(
      child: Container(
        margin: EdgeInsets.symmetric(vertical: 10),
        height: animation.value,
        width: animation.value,
        child: FlutterLogo(),
      ),
    );


  }

}
